package com.qubuyer.business.payment.activity

import android.view.View
import com.qubuyer.R
import com.qubuyer.bean.event.GoToMainEvent
import com.qubuyer.business.main.MainActivity
import com.qubuyer.business.order.activity.OrderListActivity
import com.qubuyer.core.app.DataBindingFragment
import com.qubuyer.core.utils.ActivityManager.Companion.finishExcept
import com.qubuyer.databinding.FragmentPayResultBinding
import com.qubuyer.utils.EventBusUtil
import com.qubuyer.utils.NavigationUtil

/**
 * @author Susong
 * @date 创建时间:2019/3/19
 * @description 支付结果activity
 * & @version
 */
class PaymentResultFragment : DataBindingFragment<FragmentPayResultBinding>() {

    fun onClick(v: View) {
        when (v.id) {
            R.id.tv_operation_one -> {
                EventBusUtil.sendEvent(GoToMainEvent())
                finishExcept(MainActivity::class.java)
            }
            R.id.tv_operation_two -> {
                finishExcept(MainActivity::class.java)
                NavigationUtil.overlay(mContext, OrderListActivity::class.java)
            }
        }
    }

    override fun onBackPressed(): Boolean {
        mContext.finish()
        return true
    }

    override fun onDataBinding(dataBinding: FragmentPayResultBinding) {
        dataBinding.host = this
    }

    override val layoutId: Int
        get() = R.layout.fragment_pay_result
}